﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.OleDb;
using DTO;
namespace DAO
{
    public class KhachHangDAO
    {
        public List<DTO.KhachHangDTO> SelectAll()
        {
            List<DTO.KhachHangDTO> danhSach = new List<KhachHangDTO>();
            string sql = "SELECT * FROM KhachHang";
            OleDbConnection conn = DataProvider.ConnectDB();
            OleDbCommand cmd = new OleDbCommand(sql, conn);
            OleDbDataReader reader = cmd.ExecuteReader();
            while (reader.Read())
            {
                KhachHangDTO kh = new KhachHangDTO();
                kh.MaKH = reader.GetInt32(0);
                kh.TenKH = reader.GetString(1);
                kh.SoDT = reader.GetString(2);
                kh.DiaChi = reader.GetString(3);
                danhSach.Add(kh);
            }
            conn.Close();
            return danhSach;
        }
    }
}
